import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class PokerGame {
    //创建牌盒并将数据进行拼接添加
    static ArrayList<String> poker = new ArrayList<>();
    //创建集合方便对发的牌进行排序

    static {
        //创建牌盒存入牌的数据
        String[] color = {"♠", "♣", "♥", "♦"};
        String[] number = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
        for (String s : color) {
            for (String str : number) {
                poker.add(s + str);
            }
        }
        //添加好数据后还需要添加大小王
        poker.add("大王");
        poker.add("小王");
    }

    public PokerGame() {
        //洗牌方便发牌
        Collections.shuffle(poker);
        //创建底牌集合
        ArrayList<String> lord = new ArrayList<>();
        //创建三位玩家
        ArrayList<String> gamer1 = new ArrayList<>();
        ArrayList<String> gamer2 = new ArrayList<>();
        ArrayList<String> gamer3 = new ArrayList<>();
        //对集合进行遍历进行发牌
        for (int i = 0; i < poker.size(); i++) {
            if (i <= 2) {
                //作为底牌
                lord.add(poker.get(i));
            }
            //进行取模按照顺序进行发牌
            if (i % 3 == 0) {
                gamer1.add(poker.get(i));
            } else if (i % 3 == 1) {
                gamer2.add(poker.get(i));
            } else {
                gamer3.add(poker.get(i));
            }
        }
        //发完牌进行看牌
        lookPoker("底牌", lord);
        lookPoker("Jack", gamer1);
        lookPoker("Tom", gamer2);
        lookPoker("Mary", gamer3);
    }

    private void lookPoker(String name, ArrayList<String> poker) {
        System.out.print(name + " : ");
        for (String s : poker) {
            System.out.print(s + " ");
        }
        System.out.println();
    }

}
